/*
 * Created on Tue Dec 28 16:23:09 CET 2010
 */

/* 
 * This Bundle implements a service who simulate a sensor and expose the hydrometry value regularly.
 */

package org.ece.meteo.capteurHydro;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {
	
	static BundleContext BC;
	Thread c_hydro1;
	
	/**
	 * Implements Activator.start(). Prints that it is starting,
	 * implements c_hydro1 as CapteurHydro() thread and start it. 
	 * @param context the framework context for the bundle.
	**/
	  public void start(BundleContext context) throws Exception {
		  BC = context;
		  c_hydro1 = new CapteurHydro();
		  c_hydro1.start();		// Start thread
		  System.out.println("> org.ece.meteo.capteurHydro started");	
	  }
	
	/**
	 * Implements Activator.stop(). Prints that it is stopping and
	 * stop the CapteurHydro() thread. 
	 * @param context the framework context for the bundle.
	**/
	  public void stop(BundleContext context) throws Exception {
		   ((CapteurHydro) c_hydro1).halt();	// stop thread
		   System.out.println("> org.ece.meteo.capteurHydro resolved");
	  }
	}